Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ability to create mail merge fields inside Caracal documents #120

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

danielrhodes
Copy link

@danielrhodes danielrhodes commented Apr 22, 2019

Was recently in need of adding a mail merge field in document generated by Caracal. For those not familiar, mail merge fields are treated as a simple or complex field in OOXML. Even though mail merge fields (e.g. «=replace_me») are relatively straightforward in appearance, Word and libraries like Sablon do not recognize mail merge fields unless they are denoted as a field and treated in a special way.

This pull request adds the ability to create mail merge fields as simple fields and also auto-detects mail merge fields inside paragraph text, meaning you can use them in places like Caracal's tables without having to make any other changes.

Some examples:

doc.p do
    mail_merge '=replace_me'
end

doc.table [["Name", "Profession"], ["«=name»", "«=profession»"]] do
   ...
end

Also included some tests.

Things not done: did not implement more complex mail merge types, or nested types (i.e. a nested run). However, this could easily be done.

Looking for some feedback on how this was implemented and what it would take to have this merged in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant